package com.qf.userfull.stringdemo;

/**
 * 演示String中的常用方法
 */
public class Demo02 {

    public static void main(String[] args) {

        // split的用法
//        String s = "hello world java javascript";
//        String[] split = s.split(" ");
//        System.out.println(split.length);
//
//        for (int i = 0; i < split.length; i++) {
//            System.out.println(split[i]);
//        }
        // 增强for循环
//        for (String s1 : split) {
//            System.out.println(s1);
//        }

        // 解析url
        //
        String url = "https://www.baidu.com/s?wd=onepice&rsv_spt=1&rsv_iqid=0x9221d6ec00003b07&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_enter=1&rsv_dl=tb&rsv_sug3=9&rsv_sug1=6&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&inputT=2744&rsv_sug4=5038\n";
        String[] result = url.split("[?=&]");
        System.out.println(result.length);

        for (int i = 1; i < result.length; i++) {
//            System.out.println(result[i]);
            System.out.println(result[i]+"->"+result[++i]);
        }


    }

}
